package finalgame.Engine.trainer;

import finalgame.Engine.pokemon.Pokemon;
import finalgame.Graphics.Location;

public class Trainer {
	protected Pokemon[] pokemon;
	protected int pokemonNumber;
	protected int activePokemon;
	protected String name;
	protected Location myLoc;
	
	public Trainer(){
		pokemonNumber = 0;
		pokemon = new Pokemon[6];
		activePokemon = 0;
		name = "Garry";
	}
	public Trainer(Pokemon[] sentPokemon, String n) {		
		pokemon = sentPokemon;
		pokemonNumber = sentPokemon.length;
		activePokemon = 0;
		name = n;
	}

	public void switchPokemon(int newactive) {
		activePokemon = newactive;
	}

	public void addPokemon(Pokemon newpokemon) {
		pokemon[pokemonNumber] = newpokemon;
		pokemonNumber++;
	}
	
	public void removePokemon(int index) {
		if(pokemonNumber <= 1) return;
		for(int i = index; i < 5; i++) {
			pokemon[i] = pokemon[i+1];
		}
		pokemon[5] = null;
		pokemonNumber--;
	}
	
	public Pokemon getCurrentPokemon() {
		return pokemon[activePokemon];
	}
	
	public Pokemon[] getPokemonInventory(){
		return pokemon;
	}
	
	public int getNumberOfPokemon(){
		return pokemonNumber;
	}
	
	public String getName(){
		return name;
	}
	
	public void setLoc(Location loc) {
		myLoc = loc;
	}
	
	public Location getLocation() {
		return myLoc;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public boolean isBeaten() {
		for(int i = 0; i < pokemonNumber; i++) {
			if(pokemon[i].getHP() > 0) return false;
		}
		return true;
	}
}
